<?php

namespace App\Models;

use App\Traits\ModelEventTrait;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * App\Models\BrandModel
 *
 * @property int id
 * @property string delete_time
 * @property string name
 * @property int status
 * @property string cover_img
 */
class BrandModel extends BaseModel
{
    use ModelEventTrait;
    use SoftDeletes;

    const KEY = 'id';
    const TABLE = 'sp_brand';

    protected $table = self::TABLE;
    protected $primaryKey = self::KEY;
    protected $connection = 'mysql';

    // public $timestamps = false;
    const CREATED_AT = 'create_time';
    const UPDATED_AT = 'update_time';
    const DELETED_AT = 'delete_time';

    protected $guarded = [];

    protected $appends = [];

    protected $hidden = [];

    protected $casts = [
        'create_time' => 'datetime:Y-m-d H:i:s',
        'update_time' => 'datetime:Y-m-d H:i:s',
        'delete_time' => 'datetime:Y-m-d H:i:s',
    ];

    public static function findById($id)
    {
        return self::query()->find($id);
    }

    public function getAll()
    {
        return (new static())->select('id','name','status')->get();
    }
}
